package com.bwie.es.sync;

import com.bwie.common.domain.Ticket;
import com.bwie.common.result.Result;
import com.bwie.es.remote.TicketFeignService;
import com.bwie.es.service.ESService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Log4j2
public class TicketSync {
    @Autowired
    private TicketFeignService ticketFeignService;
    @Autowired
    private ESService esService;

    @Scheduled(cron = "0/20 * * * * ?")
    public void TicketSync(){
        Result<List<Ticket>> list = ticketFeignService.list();
        List<Ticket> data = list.getData();

        esService.bulk(data);
    }
}
